import xyz.migle.util.ZipClassLoader
import java.io.File
import java.time.LocalDate
import java.time.Period

fun Int.day() = Period.ofDays(this)
fun Period.ago() = LocalDate.now() - this


fun main(args: Array<String>) {
//    println(File(".").absolutePath)
//    println(j002.onExecute().jobName)
//    val f = File("C:\\workspace\\idea\\sqldsl\\tmp\\tmp.zip").toURL()
//    val myClassLoader = URLClassLoader(
//            arrayOf<URL>(f), Thread.currentThread().contextClassLoader)
//    println(myClassLoader==null)
//    val myClass = myClassLoader.loadClass("Test")
//    val job = myClass.newInstance()



    val loader = ZipClassLoader("C:\\workspace\\idea\\sqldsl\\demo\\test.jar")
    //Kotlin编码生成的类名为 ”filename+Kt“首字母会大写,可以在”@file:JvmName("Test")“来自定义
    val cls = loader.loadClass("DemoMysqlKt")
    println(cls == null)
    //get+脚本中的变量名，后面要以做为按类型遍历，找到此方法，更加灵活
    val m = cls.getDeclaredMethod("getMysqlDemo")
    println(m == null)
    val invoke:KotJob =  m.invoke(cls) as KotJob
    println(invoke.onExecute())

//    println(job.name)

}